package com.alibaba.sdk.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * 统一事件执行器
 *
 * @ author  Shawn(Shawn_0217@163.com)
 * @ date    2021/12/23 16:33
 * @ version 1.0
 */
@Component
public class ActionContext {

    @Autowired
    private ApplicationContext act;

    public <P, R> R execute(Class<?> actionClass, P p) {
        OperateAction<P, R> action = (OperateAction<P, R>) act.getBean(actionClass);
        return action.execute(p);
    }
}
